package es.udc.fic.hamneggs.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import es.udc.fic.hamneggs.R;

public class ItemAdapter extends BaseAdapter {
	  protected Activity activity;
	  protected String[] items;
	         
	  public ItemAdapter(Activity activity, String[] items) {
	    this.activity = activity;
	    this.items = items;
	  }
	 
	  @Override
	  public int getCount() {
	    //return items.size();
		  return items.length;
	  }
	 
	  @Override
	  public Object getItem(int position) {
	    return items[position];//items.get(position);
	  }
	 
	  @Override
	  public long getItemId(int position) {
	    //return items.get(position);
		  return position;
	  }
	 
	  @Override
	  public View getView(int position, View contentView, ViewGroup parent) {
	    View vi=contentView;
	         
	    if(contentView == null) {
	      LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	      vi = inflater.inflate(R.layout.list_item_layout, null);
	    }
	             
	    String item = items[position];//items.get(position);
	        
	    TextView nombre = (TextView) vi.findViewById(R.id.nombre);
	    nombre.setText(item);
	   
	    return vi;
	  }
	}